using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;

//创建时间：2025-02-27
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// OP60盖板底座焊丝组合
    /// </summary>
    [Verify]
    [Route("business/DcOp60Record")]
    [ApiExplorerSettings(GroupName = "business")]
    public class DcOp60RecordController : BaseController
    {
        /// <summary>
        /// OP60盖板底座焊丝组合接口
        /// </summary>
        private readonly IDcOp60RecordService _DcOp60RecordService;

        public DcOp60RecordController(IDcOp60RecordService DcOp60RecordService)
        {
            _DcOp60RecordService = DcOp60RecordService;
        }

        /// <summary>
        /// 查询OP60盖板底座焊丝组合列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "dcop60record:list")]
        public IActionResult QueryDcOp60Record([FromQuery] DcOp60RecordQueryDto parm)
        {
            var response = _DcOp60RecordService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询OP60盖板底座焊丝组合详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "dcop60record:query")]
        public IActionResult GetDcOp60Record(long Id)
        {
            var response = _DcOp60RecordService.GetInfo(Id);
            
            var info = response.Adapt<DcOp60RecordDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加OP60盖板底座焊丝组合
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "dcop60record:add")]
        [Log(Title = "OP60盖板底座焊丝组合", BusinessType = BusinessType.INSERT)]
        public IActionResult AddDcOp60Record([FromBody] DcOp60RecordDto parm)
        {
            var modal = parm.Adapt<DcOp60Record>().ToCreate(HttpContext);

            var response = _DcOp60RecordService.AddDcOp60Record(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新OP60盖板底座焊丝组合
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "dcop60record:edit")]
        [Log(Title = "OP60盖板底座焊丝组合", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateDcOp60Record([FromBody] DcOp60RecordDto parm)
        {
            var modal = parm.Adapt<DcOp60Record>().ToUpdate(HttpContext);
            var response = _DcOp60RecordService.UpdateDcOp60Record(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除OP60盖板底座焊丝组合
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "dcop60record:delete")]
        [Log(Title = "OP60盖板底座焊丝组合", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteDcOp60Record([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<long>(ids);

            return ToResponse(_DcOp60RecordService.Delete(idArr));
        }

    }
}